package com.ruoyi.project.ums.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.db.ums.domain.UmsUser;
import com.ruoyi.db.ums.domain.query.UmsUserQueryVo;
import com.ruoyi.project.ums.service.UmsUserService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 会员管理Controller
 *
 * @author ruoyi
 * @date 2020-04-22
 */
@Api(tags="ums管理：会员管理管理")
@RestController
@RequestMapping("/ums/VipUser")
public class UmsUserController extends BaseController
{
    @Autowired
    private UmsUserService umsUserService;

    @ApiOperation("查询会员管理列表")
    @PreAuthorize("@ss.hasPermi('ums:VipUser:list')")
    @GetMapping("/list")
    public TableDataInfo list(UmsUserQueryVo umsUserQueryVo)
    {
        startPage();
        List<UmsUser> list = umsUserService.selectUmsUserList(umsUserQueryVo);
        return getDataTable(list);
    }

    @ApiOperation("导出会员管理列表")
    @Log(title = "会员管理", businessType = BusinessType.EXPORT)
    @PreAuthorize("@ss.hasPermi('ums:VipUser:export')")
    @GetMapping("/export")
    public AjaxResult export(UmsUserQueryVo umsUserQueryVo)
    {
        List<UmsUser> list = umsUserService.selectUmsUserList(umsUserQueryVo);
        ExcelUtil<UmsUser> util = new ExcelUtil<UmsUser>(UmsUser.class);
        return util.exportExcel(list, "VipUser");
    }

    @ApiOperation("获取会员管理详细信息")
    @Log(title = "会员管理", businessType = BusinessType.OTHER)
    @PreAuthorize("@ss.hasPermi('ums:VipUser:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(umsUserService.selectUmsUserById(id));
    }

    @ApiOperation("新增会员管理")
    @Log(title = "会员管理", businessType = BusinessType.INSERT)
    @PreAuthorize("@ss.hasPermi('ums:VipUser:add')")
    @PostMapping
    public AjaxResult add(@RequestBody UmsUser umsUser)
    {
        return toAjax(umsUserService.insertUmsUser(umsUser));
    }

    @ApiOperation("修改会员管理")
    @Log(title = "会员管理", businessType = BusinessType.UPDATE)
    @PreAuthorize("@ss.hasPermi('ums:VipUser:edit')")
    @PutMapping
    public AjaxResult edit(@RequestBody UmsUser umsUser)
    {
        return toAjax(umsUserService.updateUmsUser(umsUser));
    }

    @ApiOperation("删除会员管理")
    @Log(title = "会员管理", businessType = BusinessType.DELETE)
    @PreAuthorize("@ss.hasPermi('ums:VipUser:remove')")
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(umsUserService.deleteUmsUserByIds(ids));
    }
}
